const myArray = [1, 2, [3, 4, 5, [6, [7]]], 8, [9]]

function concatFlatten(array) {
	while (array.some(item => Array.isArray(item))) {
		array = [].concat(...array);
	}
	return array;

}

const concatArray = concatFlatten(myArray)
console.log(concatArray);
